<?php
namespace app\app\controller;
use think\Db;
class Order extends Common
{
     public function get_detail()
     {
        $order_id = request()->request('order_id');
        $msg['state'] = 0;
        $msg['data'] = json('');
        if(empty($order_id)){
            $msg['msg'] = 'order_id not have';
        }else{
            $where['order_id'] = $order_id;
            $fields = 'order_id,key,ident,cate_id,type,price,place_lng,place_lat,place_phone,place_name,place_truename,place_address,target_lng,target_lat,target_phone,target_name,target_truename,target_address,remark,image1,image2,image3,audio,issue_time,receive_time,complete_time,status,shop_charge,tip,express_charge,express_get_money,flag,discount,audio_length,require_time,express';
            $data = Db::table('order')->field($fields)->where($where)->find();
            if(count($data) == 0){
                $msg['msg'] = '订单号不存在！';
            }else{
                $msg['state'] = 1;
                if(!empty($data['discount'])){
                    $discount_info = Db::table('user_discounts')->where('id',$data['discount'])->find();
                    $data['discount_type'] = $discount_info['type'];
                    $data['discount_minus'] = $discount_info['minus'];
                }else{
                    $data['discount_type'] = '';
                    $data['discount_minus'] = '';
                }
                if(!empty($data['express'])){
                    $express = Db::table('user')->where('id',$data['express'])->find();
                    $data['express_name'] = $express['true_name'];
                    $data['express_phone'] = $express['phone'];
                }else{
                    $data['express_name'] = '';
                    $data['express_phone'] = '';
                }
                $data['cate'] = Db::table('service_category')->where('id',$data['cate_id'])->value('title');
                foreach ($data as $k2 => $data2){
                    if($data2 == null){
                        $data[$k2] = '';
                    }
                }
                $msg['data'] = $data;
                $msg['msg'] = '获取成功';
            }
        }
        return json($msg);
    }
}